/**
 * Created with IntelliJ IDEA.
 * Description:线程状态
 * User: lenovo
 * Date: 2022-09-05
 * Time: 23:22
 */
public class Demo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 10000_0000; i++) {

            }
                //什么都不做
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

        });
        //New 线程创建前
        System.out.println(t.getState());
        t.start();
        //main线程休眠一会,避免t线程还未进入休眠就得到状态,runnable
        //timed_waiting t线程正在休眠
        Thread.sleep(30);
        System.out.println(t.getState());
        t.join();
        //timed_waiting 线程执行结束
        System.out.println(t.getState());
    }
    public static void main0(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 10000; i++) {
               //什么都不做
            }
        });
        //New 线程创建前
        System.out.println(t.getState());
        t.start();
        //runnable t线程正在执行
        System.out.println(t.getState());
        t.join();
        //timed_waiting 线程执行结束
        System.out.println(t.getState());
    }
}
